#include "common.h"

int main() {
    key_t key = getKey();
    printf("key: 0x%x\n", key);
    int shm_id = creatShm(key);
    printf("shm_id: %d\n", shm_id);

    char* start = (char*)attachShm(shm_id);
    printf("attach success, address start: %p\n", start);

    struct shmid_ds ds;
    shmctl(shm_id, IPC_STAT, &ds);
    printf("获取属性: size: %d, pid: %d, myself: %d, key: 0x%x",\
    ds.shm_segsz, ds.shm_cpid, getpid(), ds.shm_perm.__key);

    while(true) {
        printf("client say: %s\n", start);
        sleep(3);
    }

    detachShm(start);
    deleteShm(shm_id);
    return 0;
}